package com.ruyuan.o2o.groupbuy.logcenter.hbase;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @author ming qian
 */
@Configuration
public class HBaseConfig {
    @Value("${customize.hbase.host}")
    public String host;

    @Value("${customize.hbase.zkPort}")
    public String port;

    @Bean
    public Connection getHbaseService() throws IOException {
        org.apache.hadoop.conf.Configuration config = HBaseConfiguration.create();
        String zkAddress = host + ":" + port;
        config.set(HConstants.ZOOKEEPER_QUORUM, zkAddress);
        return ConnectionFactory.createConnection(config);
    }
}
